#include "stdafx.h"
#include "Cardstack.h"


Card Cardstack::look_at(int no)
{
	assert(no >= 1 && no <= number);
	return stack[number - no];
};

Card Cardstack::deal_top()
{
	assert(number>0);
	return stack[--number];
};

void Cardstack::lay_top(Card k)
{
	assert(number<52);
	stack[number++] = k;
};

void Cardstack::new_pack()
{
	int n=0;
	for(suit f=clubs; f<=spades; f=suit(f+1))
		for(int v = 1; v<= 13; v++)
			stack[n++] = Card(f,v);

	number = 52;
};

void Cardstack::shuffle()
{
	srand(time(0));
	for (int i =1; i<1000; i++)
	{
		int n1 = rand() %number;
		int n2 = rand() %number;
		Card temp = stack[n1];
		stack[n1] = stack[n2];
		stack[n2] = temp;
	}
};